<%@ page import="com.apexedu.identity.entity.TSysUser"%>
<%@ page import="com.apexedu.identity.IdConstants"%>
<%@ page import="com.apexedu.identity.security.CasLoginUtil"%>
<%@ page import="com.apexedu.framework.util.SysPropertiesUtil"%>
<%@ page import="com.apexedu.util.StringUtil"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%
	request.setAttribute("basePath", request.getContextPath());
	TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
	if (null != user) {
		request.setAttribute("userid", user.getUserloginid());
		request.setAttribute("username", user.getUsername());
	}
%>
<style>
#main #right #head {
	background: #8c1515;
}

#main #right #head .titleSpan {
	left: 0px;
}

#head .label, .badge {
	background-color: #999;
	color: #fff;
	display: inline-block;
	font-size: 11.844px;
	font-weight: bold;
	line-height: 14px;
	padding: 2px 4px;
	text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
	vertical-align: baseline;
	white-space: nowrap;
}

#head .badge {
	border-radius: 9px;
	padding-left: 7px;
	padding-right: 7px;
}

.label-important, .badge-important {
	background-color: #b94a48;
}
</style>
<script>
  setInterval(function(){
    $.get("${basePath}keepsession.jsp",{},function(data){});
  }, 60000);  //每1分钟请求一次，保持session活动。

  var basePath = '${basePath}';
  function execLogout() {
    <%if (CasLoginUtil.isSsoEnabled()) {
				// 通知业务系统liveBos登出。
				// 这里的地址是根据项目现场业务系统地址在门户管理后台的系统参数维护里修改。参数名用“livebos.urls”
				String liveBosUrl = SysPropertiesUtil.get("livebos.urls");
				if (StringUtil.isNotBlank(liveBosUrl)) {
					String[] liveBosUrls = liveBosUrl.split(",");
					for (String url : liveBosUrls) {
						out.println("$(\"<iframe src='" + url
								+ "/logout.do' height='0' frameborder='0'/>\").appendTo(\"body\");");
					}
				}
			}%>
    $.get("${basePath}/identity/ajaxlogin.action?act=logout", {q: (new Date()).getTime()}, function (data) {
      data = eval("(" + data + ")");
      if (data.msg == 'success') {
        <%if (CasLoginUtil.isSsoEnabled()) {%>
        window.location.href = '<%=CasLoginUtil.getCasServerLogoutUrl()%>';
        <%} else {%>
        window.location.href = '<%=request.getContextPath()%>?t=' + Math.round(new Date / 1000);
        <%}%>
      } else {
        alert(data.msg);
      }
    });

  }
</script>
<div id="head">
	<span class="titleSpan" onclick="window.location.href='${basePath}/'"></span>
	<%--   <div class="more" onclick="window.location.href='${basePath}/s/m/index'"> --%>
	<!--     <span id="unreadMessage"  style="margin-left: 8px;margin-top: -6px;display: none" class="badge badge-important">0</span> -->
	<!--   </div> -->

	<div style="float:left; margin-top:-5px">
		<img src="${basePath}/resources/index/img/9.png">
	</div>
	<div class="info" style="color:white">
		${username}
		<img alt="用户头像" src="${basePath}/userinfo/${userid}" style="width: 34px; height: 34px; margin-left: 10px;" onerror="this.src='${basePath}/userinfo/user_male_portrait.png'">
		<span class="mask"></span>
		<div class="headMenu">
			<ul>
				<%
					if ("admin".equals(user.getUserloginid())) {
				%>
				<li onclick="window.location.href='${basePath}/identity/index.action?flag=true'">
					<div class="htgl">管理后台</div>
				</li>
				<%
					}
				%>
				<li onclick="window.open('${basePath}/s/uc/mh/up')">
					<div class="mmxg">密码修改</div>
				</li>
				<li onclick="window.open('${basePath}/s/uc/mh/hp')">
					<div class="txsw">头像上传</div>
				</li>
				<li class="zx" onclick="execLogout()">
					<div>注&nbsp;&nbsp;销</div>
				</li>
			</ul>
		</div>
	</div>
</div>

<%--显示未读信息--%>
<jsp:include page="message/unread.jsp" />